<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>上传题目</title>
	<script src='/static/js/jquery-1.12.1.min.js'></script>
	<script src='/static/js/kindeditor/kindeditor-all-min.js'></script>
</head>
<body>

		标题:<input type="text" style="width:500px" id="t1">

		<br /><br />
		
		公司:<input type="text" style="width:500px" id="t3" placeholder="选填">

		<br /><br />
		答案:<textarea id="t2" style="width: 500px;height:400px;"></textarea>
		
		<br /><br />
		<input id="myb" type="button" value="提交" onclick="sub()" />


    <script>


initKindEditor();

     
function initKindEditor() {
	var kind = KindEditor.create('#t2', {
		//uploadJson:'/md_admin/imageupload', 
		width: '600px',       // 文本框宽度(可以百分比或像素)
		height: '300px',     // 文本框高度(只能像素)
		minWidth: 200,       // 最小宽度（数字）
		minHeight: 400      // 最小高度（数字）
	});
}

		function sub(){

			var content = $(document.getElementsByTagName("iframe")[0].contentWindow.document.body).html()

var aj1 = $.ajax({
    type: "POST",
    url:"/insert",
        async:true,
        dataType:'json',
        data:{'title':$("#t1").val(),'desc':content,'com':$("#t3").val()},
		beforeSend: function(){
     // Handle the beforeSend event
	 $('#myb').attr("disabled",true);
    },
    complete: function(){
     // Handle the complete event
	 $('#myb').attr("disabled",false);
    },
    success: function(msg){
		alert(msg.result);
		
		if(msg.result != '重复数据'){
		
		$("#t1").val("");
		$("#t2").val("");
		//$("#t3").val("");
		$(document.getElementsByTagName("iframe")[0].contentWindow.document.body).html('');

	}


    },error: function(xhr){
        alert("请求出错(接口宕机)");  
}
});

}
    
    
    </script>



    
</body>
</html>